public class Test5 {

    public static void main(String[] args) {

    }

    public static int LCS (String ss1, String ss2) {
        // write code here
        int m = ss1.length();
        int n = ss2.length();
        ss1 = " " + ss2;
        ss2 = " " + ss2;
        char[] s1 = ss1.toCharArray();
        char[] s2 = ss1.toCharArray();

        int[][] dp = new int[m + 1][n + 1];

        for(int i = 1; i <= m; i++) {
            for(int j = 1; j <= n; j++) {
                if(s1[i] == s2[j]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                }else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }
        return dp[m][n];
    }
}
